home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload Trio 2
/
Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO
/
dir31
/
tnypl211.zip
/
EX0.C
next >
Wrap
C/C++ Source or Header
|
1994-06-21
|
2KB
|
80 lines
/* ex0.c - example #0 */
#include <stdio.h>
#include <conio.h>
#include <malloc.h>
#include <io.h>
#include <fcntl.h>
#ifdef __BORLANDC__
#include <dos.h>
#else
#include <i86.h>
#endif
#include "modplay.h"
/* the volume level goes from 0 to 255 */
#define MUSICVOLUME 192
void FadeInMusic(void)
{
int Volume;
for (Volume = 0; Volume <= MUSICVOLUME; Volume++) {
MODSetMusicVolume(Volume);
delay(6);
}
}
void FadeOutMusic(void)
{
int Volume;
for (Volume = MUSICVOLUME; Volume >= 0; Volume--) {
MODSetMusicVolume(Volume);
delay(10);
}
}
void TestSample(void)
{
Sample *Ding;
if ((Ding = MODLoadSample("SAMPLE.WAV")) != NULL) {
printf("Press any key to test the WAV file and ESC to exit.\n");
while (getch() != 27)
MODPlaySample(7,Ding);
MODFreeSample(Ding);
}
else {
printf("Error loading WAV file. Press any key to exit.\n");
getch();
}
}
void main(void)
{
Module *Song;
word Port;
byte IRQ,DRQ;
if (MODDetectCard(&Port,&IRQ,&DRQ)) {
printf("Sound Blaster not found.\n");
return;
}
printf("Sound Blaster found at Addr:%03x IRQ:%d DMA:%d\n",Port,IRQ,DRQ);
if ((Song = MODLoadModule("TUNE.MOD")) != NULL) {
if (MODPlayModule(Song,8,22222,Port,IRQ,DRQ,PM_TIMER))
printf("Error initializing the sound system.\n");
else {
printf("Playing music...\n");
FadeInMusic();
TestSample();
FadeOutMusic();
MODStopModule();
}
MODFreeModule(Song);
}
else {
printf("Error loading modulefile.\n");
}
return;
}